package mycommunity.dao.impl;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import mycommunity.dao.ForumDao;
import mycommunity.entity.Forum;
import mycommunity.util.HibernateUtil;

public class ForumDaoImpl implements ForumDao{
	
	@Override
	public List<Forum> getAll() {
		Session session=HibernateUtil.openSession();
		try {
			return session.createQuery("from Forum").list();
		} finally {
			// TODO: handle finally clause
			session.close();
		}
	}

	@Override
	public Forum getForumByid(int id) {
		// TODO Auto-generated method stub
		Session session=HibernateUtil.openSession();
		try {
			return (Forum) session.createQuery("from Forum where id=?").setInteger(0, id).uniqueResult();
		} finally {
			// TODO: handle finally clause
			session.close();
		}
	}
    
}
